package seteam12;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class SudokuBoardChangeEvent {
    private boolean completeRefresh;
    private List<Cell> changedCells;

    /**
     * Creates a new change event. Using this constructor signals a global
     * change.
     */
    SudokuBoardChangeEvent() {
	changedCells = new ArrayList<Cell>();
	completeRefresh = true;
    }

    /**
     * Creates a new change event. Convenience constructor taking cells
     * 
     * @param changedCells
     */
    SudokuBoardChangeEvent(Cell... changedCells) {
	if (changedCells == null || changedCells.length == 0) {
	    throw new IllegalArgumentException(
		    "List of changed cells may not be null or empty. Request a complete refresh if required!");
	} else {
	    this.completeRefresh = false;
	    this.changedCells = Arrays.asList(changedCells);
	}
    }

    /**
     * Creates a new change event. Signals that only the given cells have
     * changed.
     * 
     * @param changedCells
     */
    SudokuBoardChangeEvent(List<Cell> changedCells) {
	if (changedCells == null || changedCells.isEmpty()) {
	    throw new IllegalArgumentException(
		    "List of changed cells may not be null or empty. Request a complete refresh if required!");
	} else {
	    this.completeRefresh = false;
	    this.changedCells = changedCells;
	}
    }

    public List<Cell> getChangedCells() {
	return changedCells;
    }

    public boolean isCompleteRefreshRequired() {
	return completeRefresh;
    }
}
